package com.yumeng.framework.auth.bean.authinfo;

import com.yumeng.common.auth.BaseAuthInfo;
import com.yumeng.common.data.enums.AuthMode;
import lombok.Setter;

import java.util.Set;

/**
 * 简单用户
 * 用于一些特殊的用户信息，如OAuth用户等等
 * @author wxd
 * @date 2025/2/27 11:05
 */
@Setter
public class SimpleAuthInfo extends BaseAuthInfo {

    public SimpleAuthInfo(SimpleAuthInfoType authType, AuthMode authMode, String identityId, String identityName, String authKey, Set<String> authorities) {
        this.identityId = identityId;
        this.identityName = identityName;
        this.authKey = authKey;
        this.credentials = null;
        this.userTypes = authType.name();
        this.authMode = authMode;
        this.authorities = authorities;
    }

    private String identityId;
    private String identityName;
    private String authKey;
    private String credentials;
    private String userTypes;
    private AuthMode authMode;
    private Set<String> authorities;

    @Override
    public String getIdentityId() {
        return identityId;
    }

    @Override
    public String getIdentityName() {
        return identityName;
    }

    @Override
    public String getAuthKey() {
        return authKey;
    }

    @Override
    public String getCredentials() {
        return credentials;
    }

    @Override
    public String getSalt() {
        return "";
    }

    @Override
    public String getUserTypes() {
        return userTypes;
    }

    @Override
    public AuthMode getAuthMode() {
        return authMode;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

    @Override
    public boolean isAccountLocked() {
        return false;
    }

    @Override
    public boolean isAccountExpired() {
        return false;
    }

    @Override
    public boolean isCredentialsExpired() {
        return false;
    }

    @Override
    public Set<String> getAuthorities() {
        return authorities;
    }

    @Override
    public void eraseCredentials() {

    }

    public static enum SimpleAuthInfoType{

        OAuth2_Gitee

    }
}
